 

import java.util.ArrayList;

/**
 * Subclass to Associate
 * @author Stefan
 */
public class Supplier extends Associate
{

    private ArrayList<Delivery> deliveries;

    public Supplier(String id, String name, String address, String company)
    {
        super(id, name, address, company);
        deliveries = new ArrayList<Delivery>();
    }

    public void addDelivery(Delivery delivery)
    {
        deliveries.add(delivery);
    }

    public void clearDelivery()
    {
        deliveries.clear();
    }

    public int getSize()
    {
        return deliveries.size();
    }

    /**
     * Removes a delivery from the supplier
     * @param delivery
     */
    public void deleteDelivery(Delivery delivery)
    {
        deliveries.remove(delivery);
    }

    /**
     * finds a delivery through date. Return null if not found
     * @param date
     * @return Delivery or null (if not found)
     */
    public Delivery findDelivery(String date)
    {
        Delivery found = null;
        for (Delivery delivery : deliveries)
        {
            if (delivery.getDate().equals(date))
            {
                found = delivery;
            }
        }
        return found;
    }
}
